package com.cqie.controller.user;

import com.cqie.dto.user.PatientLoginDto;
import com.cqie.exception.SpecialException;
import com.cqie.service.IPatientLoginService;
import com.cqie.util.ResultTemplate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 不吃海鲜
 * @since 2024-11-26
 */

@Tag(name = "患者登陆Controller", description = "描述：患者登陆接口")
@RestController
@RequestMapping({"/api/v1.0/patientLogin", "/api/v1/patientLogin"})
public class PatientLoginController {

    private final IPatientLoginService patientLoginService;

    public PatientLoginController(IPatientLoginService patientLoginService) {
        this.patientLoginService = patientLoginService;
    }

    @Operation(summary = "患者注册")
    @PostMapping("/registerPatient")
    public ResultTemplate<Boolean> registerPatient(@RequestBody PatientLoginDto patientLoginDto) throws SpecialException {
        return ResultTemplate.Success(patientLoginService.registerPatient(patientLoginDto));
    }

    @Operation(summary = "患者登陆")
    @PostMapping("/loginPatient")
    public ResultTemplate<String> loginPatient(@RequestBody PatientLoginDto patientLoginDto) throws SpecialException {
        return ResultTemplate.Success(patientLoginService.loginPatient(patientLoginDto));
    }
}
